package task.manager;

import java.io.Serializable;

/**
 * Task object class.
 * 
 * @author Harrison Saylor, Aaron Mead, Marc Huet, Greg Ruskin
 * @version 2
 */
public class Task implements Serializable{
	
	/**
	 * serial version UID
	 */
	private static final long serialVersionUID = 4L;
		// Name and description variables of a task.
		private String title;
		private String description;
		private int month;
		private int day;
		private int year;
		private int hour;
		private int minute;
		private String category;
		private String placeName;
		private String address;
		
		private boolean isCompleted;
		
		/**
		 * Task constructor.
		 * 
		 * @param title Name of the task.
		 * @param minute 
		 * @param hour 
		 * @param year 
		 * @param day 
		 * @param month 
		 * @param object 
		 */
		public Task(String title, int month, int day, int year, Integer hour, Integer minute, String category){
			this(title,month,day,year,hour,minute,category,"","");
		} // End of constructor.

		public Task(String title, int month, int day, int year, Integer hour, Integer minute, String category, String placeName, String address){
			this.title=title;
			this.month = month;
			this.day = day;
			this.year = year;
			this.hour = hour.intValue();
			this.minute = minute.intValue();
			this.category = category;
			this.placeName = placeName;
			this.address = address;
		}
		
		public String getTitle() {
			
			return title;
		}

		public boolean catEquals(String activeCategory) {
			
			return category.equals(activeCategory);
		}

		public boolean getIsCompleted() {
			// TODO Auto-generated method stub
			return isCompleted;
		}

		public CharSequence getTimeString() {
			if(minute < 10){
				return "" + hour + ":0" + minute;
			}
			else{
				return "" + hour + ":" + minute;
			}
		}

		public CharSequence getDateString() {
			
			return "" + month + "-" + day + "-" + year;
		}

		public void setIsCompleted(boolean isChecked) {
			isCompleted = isChecked;
			
		}

		public boolean isComplete() {
			// TODO Auto-generated method stub
			return isCompleted;
		}

		public boolean isAfter(int month2, int day2, int year2) {
			if(!(year>year2)){
				if(!((year == year2)&&(month>month2))){
					if(!((year == year2)&&(month == month2)&&(day>day2))){
						if(!((year == year2)&&(month == month2)&&(day==day2)))
						return false;
					}
				}
			}
			return true;
		}
		
		public boolean isBefore(int month2, int day2, int year2){
			return !isAfter(month2, day2, year2);
		}

		public String getAddress() {
			if(!address.equals("")){
				return address;
			}
			return placeName;
		}

}
